package se.citerus.dddsample.data;

import org.springframework.jdbc.core.JdbcTemplate;


public class HandlingEventDataGenerator extends AbstractDataGenerator {

	public void loadHandlingEventData(JdbcTemplate jdbcTemplate) {
	    String handlingEventSql =
	      "insert into HandlingEvent (completionTime, registrationTime, type, location_id, voyage_id, cargo_id) " +
	      "values (?, ?, ?, ?, ?, ?)";

	    Object[][] handlingEventArgs = {
	        //XYZ (SESTO-FIHEL-DEHAM-CNHKG-JPTOK-AUMEL)
	        {ts(0),     ts((0)),    "RECEIVE",  1,  null,  1},
	        {ts((4)),   ts((5)),    "LOAD",     1,  1,     1},
	        {ts((14)),  ts((14)),   "UNLOAD",   5,  1,     1},
	        {ts((15)),  ts((15)),   "LOAD",     5,  1,     1},
	        {ts((30)),  ts((30)),   "UNLOAD",   6,  1,     1},
	        {ts((33)),  ts((33)),   "LOAD",     6,  1,     1},
	        {ts((34)),  ts((34)),   "UNLOAD",   3,  1,     1},
	        {ts((60)),  ts((60)),   "LOAD",     3,  1,     1},
	        {ts((70)),  ts((71)),   "UNLOAD",   4,  1,     1},
	        {ts((75)),  ts((75)),   "LOAD",     4,  1,     1},
	        {ts((88)),  ts((88)),   "UNLOAD",   2,  1,     1},
	        {ts((100)), ts((102)),  "CLAIM",    2,  null,  1},

	        //ZYX (AUMEL - USCHI - DEHAM -)
	        {ts((200)),   ts((201)),  "RECEIVE",  2,  null,  3},
	        {ts((202)),   ts((202)),  "LOAD",     2,  2,     3},
	        {ts((208)),   ts((208)),  "UNLOAD",   7,  2,     3},
	        {ts((212)),   ts((212)),  "LOAD",     7,  2,     3},
	        {ts((230)),   ts((230)),  "UNLOAD",   6,  2,     3},
	        {ts((235)),   ts((235)),  "LOAD",     6,  2,     3},

	        //ABC
	        {ts((20)),  ts((21)),   "CLAIM",    2,  null,  2},

	        //CBA
	        {ts((0)),   ts((1)),    "RECEIVE",  2,  null,  4},
	        {ts((10)),  ts((11)),   "LOAD",     2,  2,     4},
	        {ts((20)),  ts((21)),   "UNLOAD",   7,  2,     4},

	        //FGH
	        {ts(100),   ts(160),    "RECEIVE",  3,  null,   5},
	        {ts(150),   ts(110),    "LOAD",     3,  3,     5},

	        // JKL
	        {ts(200),   ts(220),    "RECEIVE",  6,  null,   6},
	        {ts(300),   ts(330),    "LOAD",     6,  3,     6},
	        {ts(400),   ts(440),    "UNLOAD",   5,  3,     6}  // Unexpected event
	    };
	    executeUpdate(jdbcTemplate, handlingEventSql, handlingEventArgs);
	}
	
}
